if (!window.Stack)
{
    var Stack = function ()
    {
        var buff = [];
        var pos = -1;

        this.size = function () { return buff.length; }
        this.push = function (value) {
            buff.push (value);
            pos ++;
        }
        this.pop = function () {
            if (pos == -1) throw "Can't popup element from empty stack";
            pos --;
            var ret = buff.pop();
//            alert ("stack.size = " + buff.length);
            return ret;
        }
        this.peek = function () { return pos == -1 ? null : buff [pos]; }
        this.isEmpty = function () { return (this.size () == 0); }
    }
}